package com.gton.lpl.common.service.impl;

import com.gton.lpl.common.service.XXLJobTaskService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @description:
 * @author: GuoTong
 * @createTime: 2022-09-06 14:16
 * @since JDK 1.8 OR 11
 **/
@Service
@Slf4j
public class XXLJobTaskServiceImpl implements XXLJobTaskService {

    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("gtJobHandler")
    public void demoJobHandler() throws Exception {
        XxlJobHelper.log("XXL-JOB, Hello World.");

        for (int i = 0; i < 5; i++) {
            XxlJobHelper.log("beat at:" + i);
            TimeUnit.SECONDS.sleep(2);
        }
        log.info("XXL-JOB  Execute Success!!!!-郭童");
        // default success
    }
}
